#ifndef LOGBUFFER_H_INCLUDED
#define LOGBUFFER_H_INCLUDED

#include <sstream>
#include <vector>
#include "timer.h"
#include "../gui/textprinter.h"

struct msg
{
	std::string str;
	unsigned int len;
	unsigned int	appeartime;
};

class Logbuffer
{
	public:
		static Logbuffer* Instance();

		void		add(const std::stringstream& streamptr);
		void		add(const std::string& msgstring);
		unsigned int	maxMessages;
		unsigned int	msgLifetime;

		unsigned int	longestLength;

		std::vector<msg*>	messages;
		void		deleteExpiredMsg();
		
		bool headless;
		pthread_mutex_t	clientmessages_mutex;
	protected:
		Logbuffer();

	private:
		static Logbuffer* _instance;
		void getLongest();

};

#endif
